﻿@*@model IEnumerable<Jobs_MVC_3_1.Models.JobPosting>*@
@model PagedList.IPagedList<Jobs_MVC_3_1.Models.JobPosting>
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @{
        if (User.IsInRole("Admin"))
        {
        @Html.ActionLink("Create New", "Create");
        }
    }
</p>
@using (Html.BeginForm())
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string) &nbsp;
        <input type="submit" value="Search" /></p>
}
<table>
    <tr>
        <th>
            PostingId
        </th>
        <th>
          @Html.ActionLink("Client Company","Index", new { Page=1, sortOrder = "ClientCompany"})
        </th>
        <th>
            Title
        </th>
        <th>
            JobCode
        </th>
        <th>
            JobType
        </th>
        <th>
            PostingDate
        </th>
        <th>
            JobStatu
        </th>
       
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.PostingId)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ClientCompany.CompanyName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.JobCode)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.JobType.JobTypeName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PostingDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.JobStatu.JobStatusName)
            </td>
            <td>
                @{
                    if (User.IsInRole("Admin"))
                    {       
                        @Html.ActionLink("Edit", "Edit", new { id = item.PostingId/* id=item.PrimaryKey */ });
                        @Html.Label("|");
                        @Html.ActionLink("Details", "Details", new { id = item.PostingId /* id=item.PrimaryKey */ });
                        @Html.Label("|");
                        @Html.ActionLink("Delete", "Delete", new { id = item.PostingId/* id=item.PrimaryKey */ });
                    }
                }
            </td>
        </tr>
    }
</table>
<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
    &nbsp;
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1})
        @Html.Raw("&nbsp;");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw("&nbsp;");
        @:< Prev
    }
    &nbsp;
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1 })
        @Html.Raw("&nbsp;");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount })
    }
    else
    {
        @:Next >
        @Html.Raw("&nbsp;")
        @:>>
    }
</div>